package com.mrd.protobuf;

import com.google.protobuf.InvalidProtocolBufferException;

/**
 * @author jack
 * @data 2019/5/7 17:34
 */
public class ProtoBufTest {
    public static void main(String[] args) throws InvalidProtocolBufferException {
        DataInfo.Student student = DataInfo.Student.newBuilder()
                .setName("j塞法")
                .setAge(11)
                .setAddress("北京")
                .build();
        byte[] student2ByteArray = student.toByteArray();
        DataInfo.Student student2 = DataInfo.Student.parseFrom(student2ByteArray);

        System.out.println(student2.getName());
        System.out.println(student2.getAge());
        System.out.println(student2.getAddress());
    }
}
